package com.aoxun.modular.dictionaryConfig.controller;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.aoxun.common.persistence.model.DictionaryConfig;
import com.aoxun.core.base.controller.BaseController;
import com.aoxun.modular.dictionaryConfig.service.IDictionaryConfigService;

/**
 * 字典配置控制器
 *
 * @author 
 * @Date 2017-07-12 18:36:41
 */
@Controller
@RequestMapping("/dictionaryConfig")
public class DictionaryConfigController extends BaseController {
	
	@Resource
	private IDictionaryConfigService iDictionaryConfigService;

    private String PREFIX = "/dictionaryConfig/";

    /**
     * 跳转到字典配置首页
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "dictionaryConfig.html";
    }

    /**
     * 跳转到添加字典配置
     */
    @RequestMapping("/dictionaryConfig_add")
    public String dictionaryConfigAdd() {
        return PREFIX + "dictionaryConfig_add.html";
    }

    /**
     * 跳转到修改字典配置
     */
    @RequestMapping("/dictionaryConfig_update/{dictionaryConfigId}")
    public String dictionaryConfigUpdate(@PathVariable Integer dictionaryConfigId, Model model) {
    	DictionaryConfig vo = iDictionaryConfigService.selectById(dictionaryConfigId+"");
        model.addAttribute("dictionaryConfig", vo);
        return PREFIX + "dictionaryConfig_edit.html";
    }

    /**
     * 获取字典配置列表
     */
    @RequestMapping(value = "/list")
    @ResponseBody
    public Object list(DictionaryConfig condition) {
        return iDictionaryConfigService.selectList(condition);
    }

    /**
     * 新增字典配置
     */
    @RequestMapping(value = "/add")
    @ResponseBody
    public Object add(DictionaryConfig vo) {
    	iDictionaryConfigService.insert(vo);
        return super.SUCCESS_TIP;
    }

    /**
     * 删除字典配置
     */
    @RequestMapping(value = "/delete")
    @ResponseBody
    public Object delete() {
        return SUCCESS_TIP;
    }


    /**
     * 修改字典配置
     */
    @RequestMapping(value = "/update")
    @ResponseBody
    public Object update(DictionaryConfig vo) {
    	iDictionaryConfigService.update(vo);
        return super.SUCCESS_TIP;
    }

    /**
     * 字典配置详情
     */
    @RequestMapping(value = "/detail")
    @ResponseBody
    public Object detail() {
        return null;
    }
}
